﻿using System;
using System.IO;
using System.Xml.Serialization;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Neovolve.Extensibility.VisualStudio.TestProfilerLink.UnitTests
{
    /// <summary>
    ///This is a test class for TestFrameworkTests and is intended
    ///to contain all TestFrameworkTests Unit Tests
    ///</summary>
    [TestClass]
    public class TestFrameworkTests
    {
        /// <summary>
        ///A test for TestFramework Constructor
        ///</summary>
        [TestMethod]
        public void TestFrameworkSerializeTest()
        {
            TestFramework target = new TestFramework();

            target.ApplicationPath = Guid.NewGuid().ToString();
            target.AssemblyTestFormat = Guid.NewGuid().ToString();
            target.AssemblyUssage = Guid.NewGuid().ToString();
            target.ClassTestFormat = Guid.NewGuid().ToString();
            target.FileUsage = Guid.NewGuid().ToString();
            target.IdentifyLoadTestByAttribute = false;
            target.LoadTestAttributeType = Guid.NewGuid().ToString();
            target.LoadTestExtension = Guid.NewGuid().ToString();
            target.LoadTestFormat = Guid.NewGuid().ToString();
            target.Name = Guid.NewGuid().ToString();
            target.SolutionUsage = Guid.NewGuid().ToString();
            target.SupportsLoadTests = true;
            target.TestClassAttributeType = Guid.NewGuid().ToString();
            target.TestMethodAttributeType = Guid.NewGuid().ToString();
            target.UnitTestFormat = Guid.NewGuid().ToString();
            target.UnitTestUsage = Guid.NewGuid().ToString();
            target.Usage = Guid.NewGuid().ToString();

            XmlSerializer serializer = new XmlSerializer(typeof(TestFramework));
            Stream stream = new MemoryStream();
            serializer.Serialize(stream, target);
            stream.Position = 0;
            StreamReader reader = new StreamReader(stream);
            String xmlData = reader.ReadToEnd();

            Assert.IsFalse(String.IsNullOrEmpty(xmlData));
        }

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get;
            set;
        }
    }
}